import java.util.Scanner;

public class Demo10 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while(!Thread.currentThread().isInterrupted()) {
                System.out.println("hello world");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    continue;
                }
            }
            System.out.println("线程 t 终止");
        });

        t.start();

        System.out.println("输入任意内容, 终止 t 线程");
        Scanner scanner = new Scanner(System.in);
        scanner.next();

        // 终止 t 线程
        t.interrupt();
    }
}
